<?php if(navigation::getAdminAction() == 'update' ): ?>
<?php
if(navigation::getAdminModeleId()>0){
    $homePage = new modele_page(navigation::getAdminModeleId());
    $data = $homePage->getDatas();
    $data['permalien'] = $homePage->getPermalien()->getCleanedLien(false);
    if($data['summary']===$homePage->generateSummary()) $data['summary'] = '';
    $action = 'update';
}else{
    $homePage = new modele_page();
    $data = $homePage->getDatas();
    $action = 'create';
}
?>
<div class="columns thirteen">
    <h1>Modifier/créer La page d'accueil</h1>
    <hr style="margin: 5px 0 15px 0;">
</div>
<form style="margin: 12px 0;" method="post" enctype="multipart/form-data" action="?template=home&action=<?php echo $action; ?>&modele=page&do=1&modele_id=<?php echo $data['id']; ?>">
    <div class="columns nine">
        <div align="right">
            <input type="submit" value="Enregistrer" class="pwe-ui-btn"/> 
            <?php if($data['id']>0): ?><a href="<?php echo $data['url']; ?>" target="_blank" title="voir la page" class="pwe-ui-btn">voir</a><?php endif; ?>
        </div>
        <?php echo $this->getInputHtml('Titre', 'modele_title', (isset($data['title']))?$data['title']:'','page', (isset($data['id']))?$data['id']:0, array('class_input'=>'titreModele','actions'=>array('onblur'=>"javascript:generatePermalien($(this).val());"))); ?>
        <?php echo $this->getInputHtml('Permalien', 'modele_lien', (isset($data['permalien']))?$data['permalien']:'','page', (isset($data['id']))?$data['id']:0, array('prefix'=>PWE::getBaseURL(),'sufix'=>modele_permalien::getExtensionByModele('page'),'id_input'=>'permalien','actions'=>array('onblur'=>"javascript:validPermalien($(this).val());"))); ?>
        <?php echo $this->getTextareaHtml('Contenu', 'modele_content', (isset($data['content']))?$data['content']:'','page', (isset($data['id']))?$data['id']:0, array('class_input'=>'editor')); ?>
        <?php include('../admin/include/inc/seoManager.inc.php'); ?>
        <div align="right">
            <input type="submit" value="Enregistrer" class="pwe-ui-btn"/> 
            <?php if($data['id']>0): ?><a href="<?php echo $data['url']; ?>" target="_blank" title="voir la page" class="pwe-ui-btn">voir</a><?php endif; ?>
        </div>
            <?php include('../admin/include/inc/redirectionManager.inc.php'); ?>
    </div>
    <div class="columns four">
        <?php include('../admin/include/inc/statutManager.inc.php'); ?>
        <br/><br/>
        <?php include('../admin/include/inc/galerieManager.inc.php'); ?>
        <br/><br/>
        <?php include('../admin/include/inc/mediaManager.inc.php'); ?>
        
        <input type="hidden" name="modele_category_id" value="<?php echo $data['category_id']; ?>" />
        <input type="hidden" name="modele_template" value="home" />
        <input type="hidden" name="modele_id" value="<?php echo $data['id']; ?>" />
    </div>
</form>
<?php endif ?>